﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Common.Logging;
using DLM.Data.EF.CodeFirst.Repositories;
using DLM.Domain.Model;
using DLM.Domain.Repositories;
using DLM.Infrastructure.Logging;
using DLM.Services.Interfaces;
using DLM.Services.Implementations;
using Quartz;
using StructureMap;
using StructureMap.Configuration;
using StructureMap.Configuration.DSL;

namespace DLM.Schedule
{
    public class CheckPartyStatusJob:IJob
    {

        // private static ILog _log = LogManager.GetLogger(typeof(CheckPartyStatusJob));
        private IScheduleService scheduleService;

        public CheckPartyStatusJob()
        {
            this.scheduleService = ObjectFactory.GetInstance<IScheduleService>();
        }

        public void Execute(IJobExecutionContext context)
        {
            // _log.Info(string.Format("Hello World! - {0}", System.DateTime.Now.ToString("r")));
            try
            {
                LoggingFactory.GetLogger().Log("CheckPart job is start!");
                this.scheduleService.CloseParty();
                LoggingFactory.GetLogger().Log("CheckPart job is end!");

                Thread.Sleep(2000);

                LoggingFactory.GetLogger().Log("Validate account job is start!");
                this.scheduleService.ValidateAccount();
                LoggingFactory.GetLogger().Log("Validate account job is end!");
            }
            catch (Exception ex)
            {

                LoggingFactory.GetLogger().Log(ex.Message);
            }
   
        }



    }
}
